package com.kyd.api.gateway.support;

import org.springframework.web.server.ServerWebExchange;

/**
 * @author zhuangqi
 * @date 2019-03-27
 */
public class GateWayExchangeUtils {

    public static final String GATEWAY_REQUEST_URL_PASS_ATTR = qualify("gatewayRequestUrlPass");

    private static String qualify(String attr) {
        return GateWayExchangeUtils.class.getName() + "." + attr;
    }


    public static void setRoutesPass(ServerWebExchange exchange) {
        exchange.getAttributes().put(GATEWAY_REQUEST_URL_PASS_ATTR, true);
    }

    public static boolean isPassRouted(ServerWebExchange exchange) {
        return exchange.getAttributeOrDefault(GATEWAY_REQUEST_URL_PASS_ATTR, false);
    }


}
